<?php
/**
 * Created by PhpStorm.
 * User: u
 * Date: 2018/12/19
 * Time: 21:14
 */
namespace common\sources\read\businessrechargerecord;

use common\models\craftsman\BusinessRechargeRecord;

class BusinessRechargeRecordAccess implements IBusinessRechargeRecordAccess
{
    public function getRechargeRecord($data)
    {
        return BusinessRechargeRecord::find()
            ->select("bus_id,amount,rech_type,status,pay_type,bank_id,order_id")
            ->where(['order_id' => $data['order_id']])
            ->asArray()
            ->one();
    }

    public function getList($data)
    {
        return BusinessRechargeRecord::find()
            ->select("order_id,create_time,remark")
            ->where(['bus_id' => $data['bus_id']])
            ->orderBy("id desc")
            ->offset(($data['page_num']-1)* $data['limit'])
            ->limit($data['limit'])
            ->asArray()
            ->all();
    }

    public function getCount($data)
    {
        return BusinessRechargeRecord::find()
                ->where(['bus_id' => $data['bus_id']])
                ->count();
    }
}